package common;

import java.beans.XMLDecoder;
import java.io.FileInputStream;
import java.io.Serializable;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;

public class Novel implements Serializable {
    //小说类
    private String novelName;
    private String novelAuthor;
    private String type;
    private String introduction;

    //方法：获取服务端所有小说的对象
    public static ArrayList getNovels(){
        ArrayList<Novel>novels=new ArrayList<>();
        try {
            XMLDecoder xd = new XMLDecoder(new FileInputStream("novels.xml"));
            novels = (ArrayList<Novel>) xd.readObject();
            xd.close();
        } catch (Exception e) {
            return novels;
        }
        return novels;
    }


    public Novel() {
    }

    public Novel(String novelName, String novelAuthor, String type, String introduction) {
        this.novelName = novelName;
        this.novelAuthor = novelAuthor;
        this.type = type;
        this.introduction = introduction;
    }

    public String getNovelName() {
        return novelName;
    }

    public void setNovelName(String novelName) {
        this.novelName = novelName;
    }

    public String getNovelAuthor() {
        return novelAuthor;
    }

    public void setNovelAuthor(String novelAuthor) {
        this.novelAuthor = novelAuthor;
    }

    public String getType() {
        return type;
    }

    public void setType(String type) {
        this.type = type;
    }

    public String getIntroduction() {
        return introduction;
    }

    public void setIntroduction(String introduction) {
        this.introduction = introduction;
    }

    @Override
    public String toString() {
        return "Novel{" +
                "novelName='" + novelName + '\'' +
                ", novelAuthor='" + novelAuthor + '\'' +
                ", type='" + type + '\'' +
                ", introduction='" + introduction + '\'' +
                '}';
    }
}
